﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DemoForGit1
{
    /// <summary>
    /// 游戏类
    /// </summary>
    class Game
    {
        private const int Cols = 6;
        private const int Rows = 4;

        private const int GameWidth = 1000;
        private const int GameHeight = 700;

        private bool IsBack;

        /// <summary>
        /// 所有块类的集合
        /// </summary>
        private List<Block> Blocks { get; set; }

        public Game()
        {
            IsBack = true;
            //初始化集合=
            Blocks = new List<Block>();
            for (int i = 0; i < Rows; i++)
            {
                for (int j = 0; j < Cols; j++)
                {
                    Blocks.Add(new Block(new Rectangle(200 + 100 * j, 50 + 150 * i, 100, 150), j + 1));
                }

                //to do switch randomly 1000 times
            }
        }
        /// <summary>
        /// 绘制当前游戏的场景
        /// </summary>
        /// <param name="g">绘图句柄</param>
        /// <param name="size">游戏区域尺寸</param>
        public void Draw(Graphics g, Size size)
        {
            //定义空白的图
            Image img = new Bitmap(GameWidth, GameHeight);

            Graphics _g = Graphics.FromImage(img);
            //定义一个矩形，长宽是预定义
            _g.DrawImage(Properties.Resources.背景, new Rectangle(0, 0, GameWidth, GameHeight));
            foreach (var block in Blocks)
            {
                block.Draw(_g);
            }

            g.DrawImage(img, new Rectangle(new Point(0, 0), size));

        }
    }


}



